package com.yifeng.repo.controller.statemachine.fsm.audit.biz;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by daibing on 2024/9/20.
 */
@Getter
@AllArgsConstructor
public enum AuditEventEnum {
    PASS(0,"同意"),
    REJECT(1,"不同意"),
    DONE(2,"已完成");

    @EnumValue
    @JsonValue
    private final Integer code;

    private final String name;

    private static final Map<Integer, AuditEventEnum> mappings = new HashMap<>(4);

    static {
        for (AuditEventEnum value : values()) {
            mappings.put(value.getCode(), value);
        }
    }

    public static AuditEventEnum resolve(Integer code) {
        return (code != null ? mappings.get(code) : null);
    }
}
